#!/usr/bin/env python
import numpy as np
from astropy.table import Table
import sys

file = sys.argv[1]
col = sys.argv[2]
row_0 = int(sys.argv[3])
row_1 = int(sys.argv[4])
worst_flag = sys.argv[5]

tab = Table.read(file,format='ipac')
data = tab[col][row_0:row_1]
if worst_flag == 'persist':
    data = abs(data)
    worst = np.max(data)
mean = np.mean(data)

if worst_flag == 'min':
    worst = np.min(data)
if worst_flag == 'max':
    worst = np.max(data)

print("data\n")
print(data)
print("mean",mean)
print("worst",worst)
